<template>
    <div>
<van-search
  v-model="valuess"
  shape="round"
  background="#4fc08d"
  placeholder="请输入搜索关键词"
/>
<div v-show="ym">
    <van-tag type="primary">标签</van-tag>
<van-tag type="success">标签</van-tag>
<van-tag type="danger">标签</van-tag>
<van-tag type="warning">标签</van-tag>

</div>
<div v-show="!ym" v-for="item in searchApiData">
    <router-link :to="{name:'dd',params:{goods_id:item.goods_id}}">
    <van-card
  :price="item.goods_price"
  :title="item.goods_name"
  :thumb="item.goods_big_logo?item.goods_big_logo:'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'"
/>
</router-link>
</div>
<van-empty description="描述文字" v-show="km"/>
    </div>
</template>

<script setup>
import { ref,watch } from 'vue';
import { searchApi } from '@/api/api';
let searchApiData=ref([])
let valuess=ref('')
let ym=ref(true)
let km=ref(false)
watch(valuess,(val)=>{
    if(val.length==0){
        ym.value=true
        km.value=false
    }else{
        ym.value=false
        searchApi(val).then(res=>{
            searchApiData.value=res.data.message.goods
            if(searchApiData.value.length==0){
                km.value=true
            }else{
                km.value=false
            }
        })
    }
})
</script>

<style lang="scss" scoped>

</style>